/* 
 * File:   TUClient.h
 * Author: arschmitz
 *
 * Created on April 3, 2011, 12:12 PM
 */

#ifndef TUCLIENT_H
#define	TUCLIENT_H
#include "TigerUpdate.h"
#include <cstdio>

/**********************************************************************\
 * TUClient                                                           *
 * TUClient is the basic class used by developers to add autoupdates  *
 * to their program.  The client connects to a server, downloads a    *
 * configuration file, and uses that to check the local versions of   *
 * files.  If the local versions are different than the server        *
 * versions, then the client will download the newer server versions. *
\**********************************************************************/
class TUClient {
public:
    TUClient();
    ~TUClient();
    int getSettings();
    int sendAndWait(TUObject *send, TUObject *waitFor);
    int hashFile(const char *fileName, char *fileHash);
    int fetchFile(TUSocket *dlServer);
private:
    TUSocket *mySendSock;
    TUSocket *myRecvSock;
    const char *myDlerAddr;
    bool parseConfig(TUFile *configFile, char expectedVersion=1);
    bool parseConfigV1(char *data);
};

#endif	/* TUCLIENT_H */

